package com.git.smp.controller;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFHyperlink;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.git.smp.cache.DataDictionaryCache;
import com.git.smp.cache.SmpSystemCache;
import com.git.smp.core.PageRequest;
import com.git.smp.core.ResponseMessage;
import com.git.smp.dao.RequireApplyMapper;
import com.git.smp.dao.RequirementBatchAnnexMapper;
import com.git.smp.dao.RequirementBatchMapper;
import com.git.smp.dao.RequirementBatchTiemMapper;
import com.git.smp.dao.SmpServiceMapper;
import com.git.smp.dao.SmpSystemCallMapper;
import com.git.smp.dao.SmpSystemMapper;
import com.git.smp.entity.ApplyAppendix;
import com.git.smp.entity.ConsumeInfo;
import com.git.smp.entity.RequireApply;
import com.git.smp.entity.RequirementBatch;
import com.git.smp.entity.RequirementBatchAnnex;
import com.git.smp.entity.RequirementBatchExtend;
import com.git.smp.entity.RequirementBatchTiemExtend;
import com.git.smp.entity.SmpField;
import com.git.smp.entity.SmpFile;
import com.git.smp.entity.SmpService;
import com.git.smp.entity.SmpServiceExtend;
import com.git.smp.entity.SmpSystem;
import com.git.smp.entity.SmpSystemCall;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@RestController
@RequestMapping("/requirementBatch")
public class RequirementBatchController {

	Logger logger = LoggerFactory.getLogger(RequirementBatchController.class);

	@Autowired
	RequirementBatchMapper requirementBatchMapper;

	@Autowired
	RequirementBatchTiemMapper requirementBatchTiemMapper;

	@Autowired
	RequireApplyMapper requireApplyMapper;

	@Autowired
	SmpServiceMapper serviceMapper;

	@Autowired
	SmpSystemCallMapper systemCallMapper;

	@Autowired
	SmpSystemMapper smpSystemMapper;
	
	@Autowired
	RequirementBatchAnnexMapper requirementBatchAnnexMapper;

	@Autowired
	private HttpServletRequest request;

	@Autowired
	private HttpServletResponse response;

	@Autowired
	private DataDictionaryCache dataDictionaryCache;
	
	
	@RequestMapping("/getRequirementBatchNum")
	public ResponseMessage<String> getRequirementBatchNum(@RequestBody RequirementBatchExtend requirementBatch){
		ResponseMessage<String> responseMessage = new ResponseMessage<String>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("信息补录成功");
		requirementBatch.setStatus("04");
		List<RequirementBatchExtend> listRequirementBatchExtend = requirementBatchMapper
				.getRequirementBatchInfoListByPage(requirementBatch);
		String batchNum ="01";
		if(listRequirementBatchExtend==null) {
			 batchNum = "01";
		}else {
			 batchNum =  String.format("%02d", listRequirementBatchExtend.size()+1);	
		}
		
		responseMessage.setExtend(batchNum);
		return responseMessage;
	}
	
	
	
	
	
	
	@RequestMapping("/updateRequirement")
	public ResponseMessage<?> updateRequirement(@RequestBody RequirementBatch requirementBatch){
		ResponseMessage<?> responseMessage = new ResponseMessage<>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("信息补录成功");
		requirementBatchMapper.updateByPrimaryKeySelective(requirementBatch);
		return responseMessage;
	}
	
	/**
	 * 修改附件
	 * @param file
	 * @param qmsNo
	 * @param batchNum
	 * @return
	 */
	@RequestMapping("/updateRequirementAnnex")
	public ResponseMessage<?> updateRequirementAnnex(
			MultipartFile[] files,
		  @RequestParam(name = "qmsNo")  String qmsNo ,
		  @RequestParam(name="batchNum") String batchNum,
		  @RequestParam(name="fileNameList") String[] fileNameList
		) {
	  	
	  	ResponseMessage<?> response = new ResponseMessage<>();
	    response.setCode("0000");
	    response.setMessage("修改成功！");
	    
	    RequirementBatchAnnex requirementBatchAnnex = new RequirementBatchAnnex();
	    requirementBatchAnnex.setQmsNo(qmsNo);
	    requirementBatchAnnex.setBatchNum(batchNum);
	    requirementBatchAnnex.setCreateDate(new Date());
	    
	    
	    // 删除不在fileList的附件
 		if (fileNameList != null && fileNameList.length > 0) {
 			requirementBatchAnnexMapper.deleteExcludeFileNames(qmsNo, batchNum, fileNameList);
 		}
	    //先删除在添加
//	    requirementBatchAnnexMapper.deleteByPrimaryKey(requirementBatchAnnex);
	    
	  	try {
	  		
	  		for (MultipartFile file : files) {
	  			requirementBatchAnnex.setFileName(file.getOriginalFilename());
	  			requirementBatchAnnex.setFileContent(file.getBytes());
	  			
	  			requirementBatchAnnexMapper.insertSelective(requirementBatchAnnex);
			}
	  		
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	  	
		return response;
	}
	
	
	@RequestMapping("appendixDown")
	public void appendixDown(@RequestBody RequirementBatchAnnex RequirementBatchAnnex) throws IOException {
		RequirementBatchAnnex requirementBatchAnnex = requirementBatchAnnexMapper.getFile(RequirementBatchAnnex);
	        OutputStream out =  response.getOutputStream();
	        out.write(requirementBatchAnnex.getFileContent());
	        out.flush();
	        out.close();
	}
	
	@RequestMapping("getFileList")
	public ResponseMessage<List<RequirementBatchAnnex>> getFileList(
			@RequestBody RequirementBatchAnnex RequirementBatchAnnex
			) {

		ResponseMessage<List<RequirementBatchAnnex>> responseMessage = new ResponseMessage<List<RequirementBatchAnnex>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询信息成功！");

		List<RequirementBatchAnnex> requirementBatchAnnexList = requirementBatchAnnexMapper
				.selectByPrimaryKey(RequirementBatchAnnex);
		
		responseMessage.setExtend(requirementBatchAnnexList);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}
	
	
	
	
	/**
	 * 查询内外联配置blob内容
	 * @param requirementBatch1
	 * @return
	 */
	@RequestMapping("esbfileDown")
	public ResponseMessage<List<?>> esbfileDown(@RequestBody RequirementBatch requirementBatch1){
		
		ResponseMessage<List<?>> responseMessage = new ResponseMessage<List<?>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");
		
		RequirementBatch requirementBatch = requirementBatchMapper.selectByPrimaryKey(requirementBatch1);

		byte[] b = requirementBatch.getEsbFile();
		String esbFile = "";
		if(b!=null) {
			 esbFile = new String(requirementBatch.getEsbFile());
		}
		
		
		byte[] b1 = requirementBatch.getOesbFile();
		String oesbFile = "";
		if(b1!=null) {
			oesbFile = new String(requirementBatch.getOesbFile());
		}
		
		
		//String oesbFile = new String(requirementBatch.getOesbFile());
		
		List<String> list = new ArrayList<>();
		list.add(esbFile);
		list.add(oesbFile);
		
		responseMessage.setExtend(list);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}
	
	

	/**
	 * 查询需求列表信息
	 * 
	 * @param pageRequest
	 * @return
	 */
	@RequestMapping("/getRequirementBatchInfoListByPage")
	public ResponseMessage<PageInfo<RequirementBatchExtend>> getRequirementBatchInfoListByPage(
			@RequestBody PageRequest<RequirementBatchExtend> pageRequest) {
		ResponseMessage<PageInfo<RequirementBatchExtend>> responseMessage = new ResponseMessage<PageInfo<RequirementBatchExtend>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询需求信息列表成功！");

		RequirementBatchExtend requirementBatchExtend = pageRequest.getBody();

		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize());
		List<RequirementBatchExtend> listRequirementBatchExtend = requirementBatchMapper
				.getRequirementBatchInfoListByPage(requirementBatchExtend);
		if (listRequirementBatchExtend.size() == 0) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("未查询到符合条件的信息！");
		}
		PageInfo<RequirementBatchExtend> pageInfo = new PageInfo<RequirementBatchExtend>(listRequirementBatchExtend,
				pageRequest.getPageSize());
		responseMessage.setExtend(pageInfo);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	/**
	 * 
	 * @param listSmpService
	 * @throws IOException
	 */
	@RequestMapping("/exportRequirement")
	public void exportRequirement(@RequestBody List<RequirementBatchExtend> listRequirementBatch) throws IOException {
		ResponseMessage<PageInfo<SmpService>> responseMessage = new ResponseMessage<PageInfo<SmpService>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");
		response.setContentType("application/octct-stream");
		buildRequirement(response.getOutputStream(), listRequirementBatch);
	}

	/**
	 * 
	 * @param pageRequest
	 * @throws IOException
	 */
	@RequestMapping("/exportAllRequirement")
	public void exportAllRequirement(@RequestBody PageRequest<RequirementBatchExtend> pageRequest) throws IOException {
		ResponseMessage<PageInfo<SmpService>> responseMessage = new ResponseMessage<PageInfo<SmpService>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");
		RequirementBatchExtend requirementBatchExtend = pageRequest.getBody();
		List<RequirementBatchExtend> listRequirementBatchExtend = requirementBatchMapper
				.getRequirementBatchInfoListByPage(requirementBatchExtend);
		response.setContentType("application/octct-stream");
		buildRequirement(response.getOutputStream(), listRequirementBatchExtend);
	}

	/**
	 * 导出需求信息
	 * 
	 * @param pageRequest
	 * 
	 * @return
	 */
	public void buildRequirement(OutputStream out, List<RequirementBatchExtend> listRequirement) {
		/*
		 * ResponseMessage<PageInfo<RequirementBatchExtend>> responseMessage = new
		 * ResponseMessage<PageInfo<RequirementBatchExtend>>();
		 * responseMessage.setCode("0000"); responseMessage.setMessage("查询成功！");
		 */

		XSSFWorkbook workbook = new XSSFWorkbook();

		XSSFFont font = workbook.createFont();
		font.setBold(true);
		font.getCTFont().addNewB();

		/**
		 * 加背景
		 */
		XSSFCellStyle cellStyle = workbook.createCellStyle();
		cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle.setAlignment(HorizontalAlignment.CENTER);

		cellStyle.setBorderBottom(BorderStyle.THIN);
		cellStyle.setBorderTop(BorderStyle.THIN);
		cellStyle.setBorderLeft(BorderStyle.THIN);
		cellStyle.setBorderRight(BorderStyle.THIN);

		/**
		 * 加背景加粗
		 */
		XSSFCellStyle cellStyle3 = workbook.createCellStyle();
		cellStyle3.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle3.setAlignment(HorizontalAlignment.CENTER);

		cellStyle3.setBorderBottom(BorderStyle.THIN);
		cellStyle3.setBorderTop(BorderStyle.THIN);
		cellStyle3.setBorderLeft(BorderStyle.THIN);
		cellStyle3.setBorderRight(BorderStyle.THIN);
		cellStyle3.setFont(font);

		/**
		 * 加边框 居中
		 */
		XSSFCellStyle cellStyle1 = workbook.createCellStyle();
		cellStyle1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1.setBorderBottom(BorderStyle.THIN);
		cellStyle1.setBorderTop(BorderStyle.THIN);
		cellStyle1.setBorderLeft(BorderStyle.THIN);
		cellStyle1.setBorderRight(BorderStyle.THIN);

		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_1 = workbook.createCellStyle();
		cellStyle1_1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1_1.setBorderBottom(BorderStyle.THIN);
		cellStyle1_1.setBorderTop(BorderStyle.THIN);
		cellStyle1_1.setBorderLeft(BorderStyle.THIN);
		cellStyle1_1.setBorderRight(BorderStyle.THIN);
		cellStyle1_1.setFont(font);
		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_2 = workbook.createCellStyle();
		cellStyle1_2.setAlignment(HorizontalAlignment.LEFT);
		cellStyle1_2.setBorderBottom(BorderStyle.THIN);
		cellStyle1_2.setBorderTop(BorderStyle.THIN);
		cellStyle1_2.setBorderLeft(BorderStyle.THIN);
		cellStyle1_2.setBorderRight(BorderStyle.THIN);

		// 获取工作表名称是Index
		Sheet sheet = workbook.createSheet("需求列表");

		// CellStyle cellStyle = workbook.createCellStyle();

		sheet.setColumnWidth(0, 20 * 256);
		sheet.setColumnWidth(1, 40 * 256);
		sheet.setColumnWidth(2, 10 * 256);
		sheet.setColumnWidth(3, 10 * 256);
		sheet.setColumnWidth(4, 40 * 256);
		sheet.setColumnWidth(5, 10 * 256);
		sheet.setColumnWidth(6, 30 * 256);
		sheet.setColumnWidth(7, 30 * 256);
		sheet.setColumnWidth(8, 30 * 256);

		Row row = sheet.createRow(0);

		String[] title = new String[] { "需求编号", "需求名称", "批次号", "主系统编号", "主系统名称", "需求状态", "申请时间", "提测时间", "生产时间", };

		for (int i = 0; i < title.length; i++) {
			Cell cell = row.createCell(i);
			cell.setCellValue(title[i]);
			cell.setCellStyle(cellStyle3);
		}

		for (int i = 0; i < listRequirement.size(); i++) {
			row = sheet.createRow(i + 1);
			Cell cell0 = row.createCell(0);
			cell0.setCellStyle(cellStyle1);
			cell0.setCellValue(listRequirement.get(i).getQmsNo());
			// String systemName =
			// smpSystemMapper.getSystemInfo(listSmpService.get(i).getSystemNo()).getSystemName();
			Cell cell1 = row.createCell(1);
			cell1.setCellStyle(cellStyle1);
			cell1.setCellValue(listRequirement.get(i).getQmsName());
			Cell cell2 = row.createCell(2);
			cell2.setCellStyle(cellStyle1);
			cell2.setCellValue(DataDictionaryCache.getItemName("SMP0010", listRequirement.get(i).getBatchNum()));
			// 交易码
			Cell cell3 = row.createCell(3);
			cell3.setCellStyle(cellStyle1);
			cell3.setCellValue(listRequirement.get(i).getMainSystemNo());

			Cell cell4 = row.createCell(4);
			cell4.setCellStyle(cellStyle1);
			cell4.setCellValue(SmpSystemCache.getSystemName(listRequirement.get(i).getMainSystemNo()));

			Cell cell5 = row.createCell(5);
			cell5.setCellStyle(cellStyle1);
			cell5.setCellValue(DataDictionaryCache.getItemName("SMP0007", listRequirement.get(i).getStatus()));

			Cell cell6 = row.createCell(6);
			cell6.setCellStyle(cellStyle1);
			try {
				cell6.setCellValue(
						new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(listRequirement.get(i).getCreateTime()));

			} catch (Exception e) {
				// TODO: handle exception
			}

			Cell cell7 = row.createCell(7);
			cell7.setCellStyle(cellStyle1);
			try {
				cell7.setCellValue(
						new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(listRequirement.get(i).getSitTime()));
			} catch (Exception e) {
				// TODO: handle exception
			}
			Cell cell8 = row.createCell(8);
			cell8.setCellStyle(cellStyle1);
			try {
				cell8.setCellValue(
						new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(listRequirement.get(i).getOprdTime()));
			} catch (Exception e) {
				// TODO: handle exception
			}
		}

		try {
			workbook.write(out);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				workbook.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}

	/**
	 * 查询需求批次信息
	 * 
	 * @param requirementBatch
	 * @return
	 */
	@RequestMapping("getRequirementBatchInfo")
	public ResponseMessage<RequirementBatchExtend> getRequirementBatchInfo(
			@RequestBody RequirementBatch requirementBatch) {

		ResponseMessage<RequirementBatchExtend> responseMessage = new ResponseMessage<RequirementBatchExtend>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询需求批次信息成功！");

		RequirementBatchExtend requirementBatchExtend = requirementBatchMapper
				.getRequirementBatchInfo(requirementBatch);

		responseMessage.setExtend(requirementBatchExtend);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	/**
	 * 查询需求对应批次工单信息
	 * 
	 * @param pageRequest
	 * @return
	 */
	@RequestMapping("getWorkOrderInfoByQmsNo")
	public ResponseMessage<PageInfo<RequireApply>> getWorkOrderInfoByQmsNo(
			@RequestBody PageRequest<RequireApply> pageRequest) {
		ResponseMessage<PageInfo<RequireApply>> responseMessage = new ResponseMessage<PageInfo<RequireApply>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("根据需求号批次分页查询对应工单信息成功！");

		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize());
		List<RequireApply> listRequireApply = requireApplyMapper.getWorkOrderInfoByQmsNo(pageRequest.getBody());

		if (listRequireApply.size() == 0) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("未查询到该需求对应批次的工单信息！");
		}
		PageInfo<RequireApply> pageInfo = new PageInfo<RequireApply>(listRequireApply, pageRequest.getPageSize());
		responseMessage.setExtend(pageInfo);
		logger.info(responseMessage.getMessage());
		return responseMessage;

	}

	@RequestMapping("updateRelaseInfo")
	@Transactional
	public ResponseMessage<?> updateRelaseInfo(@RequestBody RequirementBatchTiemExtend requirementBatchTiemExtend) {
		ResponseMessage<?> responseMessage = new ResponseMessage();
		responseMessage.setCode("0000");
		responseMessage.setMessage("需求对应批次版本的基线号更新成功！");

		Date date = new Date();
		RequirementBatch OldrequirementBatch = new RequirementBatch();

		OldrequirementBatch.setQmsNo(requirementBatchTiemExtend.getQmsNo());
		OldrequirementBatch.setBatchNum(requirementBatchTiemExtend.getBatchNum());
		RequirementBatch requirementBatch = requirementBatchMapper.selectByPrimaryKey(OldrequirementBatch);

		requirementBatch.setUpdateTime(date);
		requirementBatch.setDealUser(request.getHeader("userName"));//更改需求负责人

		// requirementBatchTiemExtend.setUpdateTime(date);
		requirementBatchTiemExtend.setDealUser(request.getHeader("userName"));
		if ("01".equals(requirementBatchTiemExtend.getRelaseType())) {
			requirementBatch.setStatus("03");
			requirementBatchTiemExtend.setStatus("03");
			requirementBatch.setSitTime(requirementBatchTiemExtend.getUpdateTime());
			requirementBatch.setEsbSitRelase(requirementBatchTiemExtend.getEsbRelase());
			requirementBatch.setOesbSitRelase(requirementBatchTiemExtend.getOesbRelase());
		} else if ("02".equals(requirementBatchTiemExtend.getRelaseType())) {
			requirementBatch.setStatus("04");
			requirementBatchTiemExtend.setStatus("04");
			requirementBatch.setOprdTime(requirementBatchTiemExtend.getUpdateTime());
			requirementBatch.setEsbOprdRelase(requirementBatchTiemExtend.getEsbRelase());
			requirementBatch.setOesbOprdRelase(requirementBatchTiemExtend.getOesbRelase());
			// 更新服务状态
			SmpService smpService = new SmpService();

			smpService.setBatchNum(requirementBatchTiemExtend.getBatchNum());
			smpService.setQmsNo(requirementBatchTiemExtend.getQmsNo());
			smpService.setStatus("02");
			serviceMapper.updateStatusByQmsNo(smpService);

			// 更新服务调用状态
			SmpSystemCall smpSystemCall = new SmpSystemCall();
			smpSystemCall.setBatchNum(requirementBatchTiemExtend.getBatchNum());
			smpSystemCall.setAssociatedRequirement(requirementBatchTiemExtend.getQmsNo());
			smpSystemCall.setStatus("02");
			systemCallMapper.updateStatusByQmsNo(smpSystemCall);

			// 更新系统状态
			SmpSystem smpSystem = new SmpSystem();
			smpSystem.setBatchNum(requirementBatchTiemExtend.getBatchNum());
			smpSystem.setAssociatedRequirement(requirementBatchTiemExtend.getQmsNo());
			smpSystem.setSystemStatus("02");

			smpSystemMapper.updateStatusByQmsNo(smpSystem);

		}

		try {
			requirementBatchMapper.updateByPrimaryKey(requirementBatch);
			requirementBatchTiemMapper.insert(requirementBatchTiemExtend);
		} catch (Exception e) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("版本更新失败！");
			e.printStackTrace();
		}
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	/**
	 * 查询需求批次信息线图
	 * 
	 * @param requirementBatch
	 * @return
	 */
	@RequestMapping("getRequirementBatchDiagram")
	public ResponseMessage<List<RequirementBatchExtend>> getRequirementBatchDiagram(
			@RequestBody RequirementBatch requirementBatch) {

		ResponseMessage<List<RequirementBatchExtend>> responseMessage = new ResponseMessage<List<RequirementBatchExtend>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询需求批次信息成功！");

		List<RequirementBatchExtend> requirementBatchExtend = requirementBatchMapper
				.getRequirementBatchDiagram(requirementBatch);

		responseMessage.setExtend(requirementBatchExtend);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

}
